<template>
  <div id="wrapper" style="padding: 20px">
    <div class="pageHeader">
      <el-page-header @back="goBack" content="编辑">
      </el-page-header>
    </div>
    <el-card class="box-card">
      <el-form :label-position="labelPosition" label-width="100px" :model="formLabelAlign">
        <el-form-item label="外传内地址">
          <el-input v-model="licenseConfig.out2inUrl"></el-input>
        </el-form-item>
        <el-form-item label="外传内帐号">
          <el-input v-model="licenseConfig.out2inUsername"></el-input>
        </el-form-item>
        <el-form-item label="外传内密码">
          <el-input v-model="licenseConfig.out2inPassword"></el-input>
        </el-form-item>
        <el-form-item label="传输位置">
          <el-input disabled v-model="licenseConfig.putLicenseDir"></el-input>
        </el-form-item>
        <el-form-item label="搜索地址">
          <el-input v-model="licenseConfig.outDatUrl"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm">修改</el-button>
          <el-button @click="reset">重置</el-button>
          <el-button @click="goBack">取消</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
  export default {
    name: 'licenseConfigDetail',
    data() {
      return {
        licenseConfig: {}
      }
    },
    methods: {
      async getLicenseConfig() {
        let res = await this.$http.get('/api/license/getLicenseConfig')
        this.licenseConfig = res.data
      },
      goBack() {
        this.$router.push('/config')
      },
      async submitForm() {
        let res = await this.$http.post('/api/license/updateLicenseConfig', this.licenseConfig)
        if(res.code == 0){
          this.$message({
            message: res.message,
            type: 'success'
          })
          this.$router.push('/licenseConfigDetail')
        }else {
          this.$message({
            message: res.message,
            type: 'error'
          })
        }
      },
      async reset() {
        let res = await this.$http.post('/api/license/resetLicenseConfig')
        if(res.code == 0){
          this.$message({
            message: res.message,
            type: 'success'
          })
          this.getLicenseConfig()
        }else {
          this.$message({
            message: res.message,
            type: 'error'
          })
        }
      }
    },
    created() {
      this.getLicenseConfig()
    }
  }
</script>

<style>
.pageHeader{
  padding: 10px;
}
</style>
